/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.brandongogetap.stickyheaders.tools;

import com.brandongogetap.stickyheaders.model.HeaderModel;
import com.brandongogetap.stickyheaders.model.ItemModel;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.util.ArrayList;
import java.util.List;

public class Utils {
    private static final String TAG = "StickyHeaders";
    private static HiLogLabel sLogLabel;
    private static final int DOMAIN = 0x001;

    private static HiLogLabel createLogLabel() {
        if (sLogLabel == null) {
            sLogLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, TAG);
        }
        return sLogLabel;
    }

    public static void debug(String format, Object... objects) {
        HiLog.debug(createLogLabel(), format, objects);
    }

    public static void error(String format, Object... objects) {
        HiLog.error(createLogLabel(), format, objects);
    }

    public static List<ItemModel> demoList() {
        List<ItemModel> items = new ArrayList<>();
        ItemModel itemModel = null;
        for (int i = 0; i < 100; i++) {
            if (i == 0 || i == 2 || i % 4 == 0) {
                itemModel = new HeaderModel("Header at " + i, "");
                if (i % 12 == 0 && i != 0) {
                    itemModel.setPaddings(new int[]{0, 100, 0, 100});
                }
            } else {
                itemModel = new ItemModel("Item at " + i, "Item description at " + i);
            }
            items.add(itemModel);
        }
        return items;
    }

}
